﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lidgren.Network;
using Microsoft.Xna.Framework;

namespace uam_fps_game.Network.MessageTypes
{
    class AddPlayer : MessagePrototype
    {
        Player player;

        public AddPlayer( Player player)
        {
            this.player = player;
        }

        public static Player ParseMessage(NetIncomingMessage im)
        {
            Vector3 pos = new Vector3(im.ReadFloat(),im.ReadFloat(),im.ReadFloat());
            return (new Player(im.ReadString(), pos));
        }

        public override void CreateMessage(ref NetOutgoingMessage om)
        {
            om.Write(player.Position.X);
            om.Write(player.Position.Y);
            om.Write(player.Position.Z);
            om.Write(player.Name);
        }
    }
}
